package top.stmo.spring.ioc.test2.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import top.stmo.spring.ioc.test2.dao.BookDao;
import top.stmo.spring.ioc.test2.service.BookService;

//@Component
@Service
public class BookServiceImpl implements BookService {

//    private BookDao bookDao = new BookDaoImpl();

    @Autowired                  //按类型自动注入
    @Qualifier("bookDaoImpl")   //在照类中注入的基础之上再照名称注入,很少使用
    private BookDao bookDao;

    @Value("${jdbc.driver}")
    private String name;

    public void save() {
        System.out.println(name);
        bookDao.save();
    }

    //提供对应的set方法
    public void setBookDao(BookDao bookDao) {
        this.bookDao = bookDao;
    }

}
